/* eslint-disable jsx-a11y/alt-text */
/* eslint-disable default-case */
/*
 * @Description:
 * @Version: 2.0
 * @Autor: zhaoyu
 * @Date: 2021-04-27 16:17:21
 * @LastEditors: zhaoyu
 * @param:
 * @return:
 * @author: zhaoyu
 */

import React from "react";
import styles from "./index.m.less";
import icon from "img/icon/search.png";
const nav = ["网站首页", "关于我们", "产品中心", "登陆/注册"];

const Header = (props) => {
  const about = (idx) => {
    switch (idx) {
      case 0:
        props.history.push("/");
        break;
      case 2:
        props.history.push("/");
        break;
      case 3:
        props.history.push("/login");
        break;
    }
  };

  const search = () => {
    props.history.push("/search");
  };

  return (
    <header className={styles.header}>
      <h1>电玩设备</h1>

      <div className={styles.search} onClick={search}>
        <img className={styles.searchIcon} src={icon} />
        搜索
      </div>

      <ul className={styles.navBar}>
        <li></li>
        {nav.map((item, idx) => (
          <li key={idx} onClick={() => about(idx)}>
            {item}
          </li>
        ))}
      </ul>
    </header>
  );
};

export default Header;
